#define _CRT_SECURE_NO_WARNINGS 2

#include<stdio.h>
#include<stdlib.h>

struct TreeNode {
	 int val;
	 struct TreeNode* left;
	struct TreeNode* right;
	
};

void InOrderTree(int* arr, int* pi,struct TreeNode* root) {
	if (!root) {
		return;
	}
	
	InOrderTree(arr, pi, root->left);
	arr[(*pi)++] = root->val;
	InOrderTree(arr, pi,root->right);
}
 
int* inorderTraversal(struct TreeNode* root, int* returnSize) {
	int* arr = (int*)malloc(sizeof(int) * 100);
	int i = 0;
	InOrderTree(arr, &i,root);
	*returnSize = i;
	return arr;
}

void CreateTree(struct TreeNode** pproot) {
	int a = 0;
	scanf("%d", &a);
	if (a == 0) {
		*pproot = NULL;
		return;
	}
	*pproot = (struct TreeNode*)malloc(sizeof(struct TreeNode));
	if (*pproot == NULL) {
		perror( "fail malloc");
		return;
	}
	(*pproot)->val = a;
	CreateTree(&((*pproot)->left));
	CreateTree(&((*pproot)->right));
}

int main() {
	struct TreeNode* root = NULL;
	CreateTree(&root);
	int len = 0;
	int* arr = inorderTraversal(root, &len);
	int i = 0;
	printf("%d\n", len);
	while (i < len) {
		printf("%d ", arr[i]);
		i++;
	}
	return 0;
}